#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import time
from common.readelement import Element
from page_object.webpage import WebPage

signinterestedresume = Element('jzsz/enterprise/sign_interestedresume')

class SignInterestedresumePage(WebPage):

    def username(self):
        """用户信息"""
        self.is_click(signinterestedresume['用户信息'])

    def get_interestedresume_num(self):
        """标记前获取已标记的简历数量"""
        self.is_click(signinterestedresume['感兴趣管理'])
        res = self.is_exists2(signinterestedresume['简历total'])
        if res:
            text = self.find_element(signinterestedresume['简历total']).text  # 获取标记前的简历总量
            resume_num = text[2:-2]
            return resume_num
        else:
            return '0'


    def go_back(self):

        self.is_click(signinterestedresume['返回'])
        # self.find_element(serchJobfair['xpath']).text


    def sign_interestedresume(self):
        """标记感兴趣的简历"""
        self.is_click(signinterestedresume['感兴趣'])
        self.is_click(signinterestedresume['确定'])


    def sign_success(self,resume_num):
        """验证标记成功"""
        self.is_click(signinterestedresume['感兴趣管理'])
        res = self.is_exists2(signinterestedresume['简历total'])
        if res:
            text = self.find_element(signinterestedresume['简历total']).text  # 获取标记后的简历总量
            resume_num2 = text[2:-2]
            if int(resume_num2) == int(resume_num) + 1:
                return True
            else:
                return False
        else:
            return False
